package com.wyc;

import com.wyc.config.ConsumerConfiguration;
import com.wyc.service.MonitorConsumer;
import com.wyc.timed.PrintMethodCost;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class DubboConsumerMain {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();
        MonitorConsumer monitorConsumer = context.getBean(MonitorConsumer.class);

        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2,2,100, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<>(10));
        Runnable consumer = new Thread(() -> monitorConsumer.consumer());
        threadPoolExecutor.submit(consumer);

        Runnable print = new Thread(() -> PrintMethodCost.print());
        threadPoolExecutor.execute(print);
    }

}
